package btp.Calendars;

public class EgyptianCalendar{
	public static final long EPOCH = JulianCalendar.getRDFromJulian(-747, JulianCalendar.FEBRUARY, 26);
	
	public static final int THOTH = 1;
	public static final int PHAOPHI = 2;
	public static final int ATHYR = 3;
	public static final int CHOIAK = 4;
	public static final int TYBI = 5;
	public static final int MECHIR = 6;
	public static final int PRAMENOTH = 7;
	public static final int PHARMUTHI = 8;
	public static final int PACHON = 9;
	public static final int PAYNI = 10;
	public static final int EPIPHI = 11;
	public static final int MESORI = 12;
	public static final int UNNAMED_MONTH = 13;
	
	int year;
	int month;
	int day;
	public EgyptianCalendar(int year, int month, int day) {
		this.year = year;
		this.month = month;
		this.day = day;
	}
		

	public long getRDFromCalendar() {
		return EPOCH + 365*(year-1) + 30*(month-1) + day-1;
	}

	
	public static EgyptianCalendar getCalendarFromRD(long rd){
		long days = rd - EPOCH; 
		int years = (int) (Math.floor(days/365.0)+1);
		int months = (int) (Math.floor((days%365)/30.0)+1);
		days -= 365*(years-1) + 30*(months-1) - 1;
		return new EgyptianCalendar(years, months, (int) days);
	}


	public final int getYear() {
		return year;
	}


	public final void setYear(int year) {
		this.year = year;
	}


	public final int getMonth() {
		return month;
	}


	public final void setMonth(int month) {
		this.month = month;
	}


	public final int getDay() {
		return day;
	}


	public final void setDay(int day) {
		this.day = day;
	}
	
	
}
